#ifndef _XML_DEF_H
#define _XML_DEF_H

#include <string>
using namespace std;

#define XML_TOOL_NAMESPACE			XmlTool
#define XML_TOOL_NAMESPACE_BEGIN	namespace XML_TOOL_NAMESPACE {
#define XML_TOOL_NAMESPACE_END		}
#define USING_XML_TOOL				using namespace XML_TOOL_NAMESPACE;

#ifdef XMLTOOL_EXPORTS
#define XML_TOOL_EXPORT __declspec(dllexport)
#else
#define XML_TOOL_EXPORT
#endif

XML_TOOL_NAMESPACE_BEGIN

class XmlNode;
typedef XmlNode* XmlNodePtr;

class XmlDocument;
typedef XmlDocument* XmlDocumentPtr;

class XmlFactory;
typedef XmlFactory* XmlFactoryPtr;

enum XmlNodeType {
	XML_ELEMENT_NODE = 1,
	XML_ATTRIBUTE_NODE,			//2
	XML_TEXT_NODE,				//3
	XML_CDATA_SECTION_NODE,		//4
	XML_ENTITY_REF_NODE,		//5
	XML_ENTITY_NODE,			//6
	XML_PI_NODE,				//7
	XML_COMMENT_NODE,			//8
	XML_DOCUMENT_NODE,			//9
	XML_DOCUMENT_TYPE_NODE,		//10
	XML_DOCUMENT_FRAG_NODE,		//11
	XML_NOTATION_NODE,			//12
} ;

class XmlNode 
{
public:
	virtual ~XmlNode() {}
	virtual bool GetAttribute(const string& attrName, string& attrValue) const = 0;
	virtual void SetAttribute(const string& attrName, const string& attrValue) = 0;
	virtual XmlNodePtr GetParent() const = 0;
	virtual XmlNodePtr GetFirstChild() const = 0;
	virtual XmlNodePtr GetLastChild() const = 0;
	virtual XmlNodePtr GetNextSibling() const = 0;
	virtual XmlNodePtr GetPrevSibling() const = 0;
	virtual const XmlDocumentPtr GetDocument() const = 0; 
	virtual string GetNodeName() const = 0;
	virtual string GetTextContent() const = 0;
	virtual XmlNodeType GetNodeType() const = 0;
	virtual void AppendChild(XmlNodePtr childNode) = 0;
	virtual string BindToXmlText(const string& encoding) = 0;
};

class XmlDocument 
{
public:
	virtual ~XmlDocument() {}
	virtual XmlNodePtr GetDocumentRoot() const = 0;
	virtual void SetDocumentRoot(XmlNodePtr xmlNode) = 0;
	virtual XmlNodePtr CreateXmlNode(const string& nodeName) = 0;
	virtual XmlNodePtr CreateTextNode(const string& nodeName, const string& nodeValue) = 0;
	virtual void ReleaseXmlNode(XmlNodePtr xmlNode) = 0;
	virtual string BindToXmlText(const string& encoding) = 0;
};

class XmlFactory
{
public:
	virtual XmlDocumentPtr CreateXmlDocument() = 0;
	virtual XmlDocumentPtr CreateXmlDocument(const string& xmlText, const string& encoding) = 0;
	virtual void ReleaseXmlDocument(XmlDocumentPtr xmlDoc) = 0;

	static XML_TOOL_EXPORT XmlFactoryPtr GetXmlFactory();
};

XML_TOOL_NAMESPACE_END

#endif //_XML_DEF_H